
import java.util.ArrayList;
import java.util.List;


public class NurseryEntityToDtoTransformer {
	enum PARENTS {
		USUAL(1),PRETENTIOUS(2), GREAT_PRET(3);
		private int code;
		
		private PARENTS(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}

	enum HAS_NURS {
		PROPER(1),LESS_PROPER(2), IMPROPER(3), CRITICAL(4), VERY_CRIT(5);
		private int code;
		
		private HAS_NURS(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	enum FORM {
		COMPLETE(1),COMPLETED(2), INCOMPLETE(3), FOSTER(4);
		private int code;
		
		private FORM(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	enum CHILDREN {
		ONE(1), TWO(2), THREE(3), MORE(4);
		private int code;
		
		private CHILDREN(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	enum HOUSING {
		CONVENIENT(1), LESS_CONV(2), CRITICAL(3);
		private int code;
		
		private HOUSING(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	enum FINANCE {
		CONVENIENT(1),INCONV(2);
		private int code;
		
		private FINANCE(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	enum SOCIAL {
		NONPROB(1), SLIGHTLY_PROB(2), PROBLEMATIC(3);
		private int code;
		
		private SOCIAL(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	enum HEALTH {
		NOT_RECOM(1), RECOMMENDED(2), PRIORITY(3);
		private int code;
		
		private HEALTH(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	
	enum CLASSIFICATION {
		NOT_RECOM(1), RECOMMEND(2), VERY_RECOM(3), PRIORITY(4), SPEC_PRIOR(5);
		private int code;
		
		private CLASSIFICATION(int code){
			this.code = code;
		}
		
		public int getCode(){
			return code;
		}
	}
	
	public List<NurseryDTO> transform(List<NurseryEntity> entities){
		System.out.println("Transforming the data...");
		List<NurseryDTO> dtos = new ArrayList<NurseryDTO>();
		for(NurseryEntity entity: entities){
			NurseryDTO dto = new NurseryDTO();
			dto.setParents(PARENTS.valueOf(entity.getParents().toUpperCase()).getCode());
			dto.setFinance(FINANCE.valueOf(entity.getFinance().toUpperCase()).getCode());
			dto.setForm(FORM.valueOf(entity.getForm().toUpperCase()).getCode());
			dto.setHas_nurs(HAS_NURS.valueOf(entity.getHas_nurs().toUpperCase()).getCode());
			dto.setHealth(HEALTH.valueOf(entity.getHealth().toUpperCase()).getCode());
			dto.setHousing(HOUSING.valueOf(entity.getHousing().toUpperCase()).getCode());
			dto.setSocial(SOCIAL.valueOf(entity.getSocial().toUpperCase()).getCode());
			dto.setClassification(CLASSIFICATION.valueOf(entity.getClassification().toUpperCase()).getCode());
			
			if(entity.getChildren().equals("more")){
				dto.setChildren(4);
			} else {
				
				dto.setChildren(Integer.parseInt(entity.getChildren()));
			}
			dtos.add(dto);
		}
		return dtos;
	}
}
